export default defineEventHandler(async (event) => {
  try {
    // 这里连接你的数据库
    // const db = await connectDatabase()
    // const songs = await db.query('SELECT * FROM music ORDER BY created_at DESC')
    
    // 模拟数据库返回的数据
    const mockSongs = [
      {
        id: 1,
        title: '数据库音乐 1',
        artist: '数据库艺术家',
        duration: '3:45',
        url: '/api/music/stream/1',
        cover: '/api/music/cover/1',
        source: 'database',
        created_at: new Date().toISOString()
      },
      {
        id: 2,
        title: '数据库音乐 2',
        artist: '数据库艺术家',
        duration: '4:12',
        url: '/api/music/stream/2',
        cover: '/api/music/cover/2',
        source: 'database',
        created_at: new Date().toISOString()
      },
      {
        id: 3,
        title: '数据库音乐 3',
        artist: '数据库艺术家',
        duration: '2:58',
        url: '/api/music/stream/3',
        cover: '/api/music/cover/3',
        source: 'database',
        created_at: new Date().toISOString()
      }
    ]
    
    return {
      success: true,
      data: mockSongs,
      total: mockSongs.length
    }
  } catch (error) {
    throw createError({
      statusCode: 500,
      statusMessage: '获取音乐列表失败'
    })
  }
})
